	var url;
	var ws;
	var obj;
	debugger
	function init() {
		getPath();
		url = path;
		ws = new WebSocket(url);
		testWebSocket(); 
		warning();
	}
	function testWebSocket() { 
        ws.onopen = function(evt) { 
            onOpen(evt) 
        }; 
        ws.onclose = function(evt) { 
            onClose(evt);
        }; 
        ws.onmessage = function(evt) { 
            onMessage(evt) 
        }; 
        ws.onerror = function(evt) { 
            onError(evt);
        }; 
    }
	window.addEventListener("load", init, false);
	//Common method body
	//���÷�����
	function onOpen(evt) { 
		ws.send("Test!");
		console.log("ws.readyState+������+open", ws.readyState);
    }  
    function onClose(evt) {
		console.log("WebSocketClosed!");
		console.log("ws.readyState", ws.readyState);
    }  
    function onMessage(evt) {
		console.log(evt.data);
		console.log("ws.readyState+@@@+message", ws.readyState);
		obj = eval(evt.data);
		console.log("?"+obj[0].value);
		warning();
    }  
    function onError(evt) {
		console.log("WebSocketError!");
		console.log("ws.readyState", ws.readyState);
    }  
    function doSend(message) {  
        ws.send(message); 
    }
	//5000 means 5000 milliseconds, that is, every 5 seconds
	// 5000��ʾ5000���룬 ��ÿ��5��ִ��һ��
	setInterval(restart, 5000); 
	function restart(){
		if(ws.readyState != 1){
			ws = new WebSocket(url);
			ws.onopen = function(evt) { 
				onOpen(evt) 
			}; 
			ws.onmessage = function(evt) { 
				onMessage(evt) 
			}; 
		};
	};